#pragma once
#include "../Common/Thread.h"
#include "Data.h"

class WriterThread : public CThread
{
public:
    WriterThread(Data* data, std::string filler)
        : CThread(), filler(filler), index(0), data(data)
    {
        srand(2341235);
    }
    ~WriterThread()
    {
    }

public:
    void run()
    {
        while(true)
        {
            char c = nextchar();
            data->write(c);
            Sleep(rand()%3000);
        }
    }

    char nextchar()
    {
        char c = filler.at(index);
        index++;
        if( index >= filler.size() )
        {
            index = 0;
        }

        return c;
    }

private:
    Data* data;
    std::string filler;
    int index;
};